package com.woniuxy.woniuticket.moviemodule.service.impl;


import com.woniuxy.woniuticket.moviemodule.dao.CinemaHallDAO;
import com.woniuxy.woniuticket.moviemodule.dao.CinemaMoviesDAO;
import com.woniuxy.woniuticket.moviemodule.dao.CinemaScheduleDAO;
import com.woniuxy.woniuticket.moviemodule.pojo.ScheduleMsg;
import com.woniuxy.woniuticket.moviemodule.service.ScheduleService;
import com.woniuxy.woniuticket.pojo.CinemaMovies;
import com.woniuxy.woniuticket.pojo.CinemaSchedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Transactional
@Service
public class ScheduleServiceImpl implements ScheduleService {
    @Resource
    private CinemaScheduleDAO scheduleDAO;
    @Resource
    private CinemaMoviesDAO moviesDAO;

    @Override
    public int insertSchedule(CinemaMovies movies, CinemaSchedule schedule) {
        return 0;
    }

    @Override
    public List<ScheduleMsg> querySchedule() {
        return null;
    }

    @Override
    public ScheduleMsg queryScheduleMsg(Integer movieId) {
        List<ScheduleMsg> mgs = scheduleDAO.queryScheduleMsg(movieId);
        if(mgs.size()>0) {
         return   mgs.get(0);
        }

        return new ScheduleMsg();
    }


    /**
     * 排片
     * @param schedule   排片对象
     * @return 成功返回1
     */
    @Override
    public int insertSchedule(CinemaSchedule schedule) {
        return scheduleDAO.insertSelective(schedule);
    }

    @Override
    public List<ScheduleMsg> queryAllSchedule(Integer page,Integer size) {
        return scheduleDAO.queryAllSchedule(page,size);
    }

    @Override
    public int delSchedule(Integer[] scheduleids) {
        return scheduleDAO.delSchedule(scheduleids);
    }

    @Override
    public int editSchedule(ScheduleMsg scheduleMsg) {

        return scheduleDAO.editSchedule(scheduleMsg);
    }

    @Override
    public List<ScheduleMsg> queryScheduleMsgList(Integer scheduleId) {
        return scheduleDAO.queryScheduleMsgList(scheduleId);
    }

    @Override
    public List<ScheduleMsg> queryScheduleMsgTime(Integer movieId, String begTime) {

        return scheduleDAO.queryScheduleMsgTime(movieId,begTime);
    }

    @Override
    public CinemaSchedule findById(Integer id) {
        return scheduleDAO.selectByPrimaryKey(id);
    }
}
